﻿Public Class RseparacionVentaDetalle

    Public Shared Function AñadirSeparacion(ByVal descEmpresa As String, ByVal pSeparacionVentaDetalle As EseparacionVentaDetalle) As Boolean
        Dim resultado As Boolean = False

        Dim options As New TransactionOptions
        options.IsolationLevel = Transactions.IsolationLevel.ReadCommitted
        options.Timeout = New TimeSpan(0, 2, 0)

        Using scope As New TransactionScope(TransactionScopeOption.Required, options)
            Try
                resultado = DseparacionVentaDetalle.AñadirSeparacion(descEmpresa, pSeparacionVentaDetalle)
                scope.Complete()
            Catch ex As Exception
                Throw
            End Try
        End Using

        Return resultado
    End Function
    Public Shared Function AñadirVenta(ByVal descEmpresa As String, ByVal pSeparacionVentaDetalle As EseparacionVentaDetalle) As Boolean
        Dim resultado As Boolean = False

        Dim options As New TransactionOptions
        options.IsolationLevel = Transactions.IsolationLevel.ReadCommitted
        options.Timeout = New TimeSpan(0, 2, 0)

        Using scope As New TransactionScope(TransactionScopeOption.Required, options)
            Try
                resultado = DseparacionVentaDetalle.AñadirVenta(descEmpresa, pSeparacionVentaDetalle)
                scope.Complete()
            Catch ex As Exception
                Throw
            End Try
        End Using

        Return resultado
    End Function
    Public Shared Function Editar(ByVal descEmpresa As String, ByVal pSeparacionVentaDetalle As EseparacionVentaDetalle) As Boolean
        Dim resultado As Boolean = False

        Dim options As New TransactionOptions
        options.IsolationLevel = Transactions.IsolationLevel.ReadCommitted
        options.Timeout = New TimeSpan(0, 2, 0)

        Using scope As New TransactionScope(TransactionScopeOption.Required, options)
            Try
                resultado = DseparacionVentaDetalle.Editar(descEmpresa, pSeparacionVentaDetalle)
                scope.Complete()
            Catch ex As Exception
                Throw
            End Try
        End Using

        Return resultado
    End Function
    Public Shared Function EditarConvertirSeparacionVenta(ByVal descEmpresa As String, ByVal pSeparacionVentaDetalle As EseparacionVentaDetalle) As Boolean
        Dim resultado As Boolean = False

        Dim options As New TransactionOptions
        options.IsolationLevel = Transactions.IsolationLevel.ReadCommitted
        options.Timeout = New TimeSpan(0, 2, 0)

        Using scope As New TransactionScope(TransactionScopeOption.Required, options)
            Try
                resultado = DseparacionVentaDetalle.EditarConvertirSeparacionVenta(descEmpresa, pSeparacionVentaDetalle)
                scope.Complete()
            Catch ex As Exception
                Throw
            End Try
        End Using

        Return resultado
    End Function
    Public Shared Function Filtrar(ByVal descEmpresa As String, ByVal pSeparacionVenta As EseparacionVenta) As List(Of EseparacionVentaDetalle)
        Dim separacionVentaDetalles As List(Of EseparacionVentaDetalle) = Nothing

        Dim options As New TransactionOptions
        options.IsolationLevel = Transactions.IsolationLevel.ReadCommitted
        options.Timeout = New TimeSpan(0, 2, 0)

        Using scope As New TransactionScope(TransactionScopeOption.Required, options)
            Try
                separacionVentaDetalles = DseparacionVentaDetalle.Filtrar(descEmpresa, pSeparacionVenta)
                If separacionVentaDetalles Is Nothing Then separacionVentaDetalles = New List(Of EseparacionVentaDetalle)
                scope.Complete()
            Catch ex As Exception
                Throw
            End Try
        End Using

        Return separacionVentaDetalles
    End Function

    Public Shared Function AñadirSeparacionTemporal(ByVal descEmpresa As String, ByVal pSeparacionVentaDetalle As EseparacionVentaDetalle) As Boolean
        Dim resultado As Boolean = False

        Dim options As New TransactionOptions
        options.IsolationLevel = Transactions.IsolationLevel.ReadCommitted
        options.Timeout = New TimeSpan(0, 2, 0)

        Using scope As New TransactionScope(TransactionScopeOption.Required, options)
            Try
                resultado = DseparacionVentaDetalle.AñadirSeparacionTemporal(descEmpresa, pSeparacionVentaDetalle)
                scope.Complete()
            Catch ex As Exception
                Throw
            End Try
        End Using

        Return resultado
    End Function
    Public Shared Function AñadirVentaTemporal(ByVal descEmpresa As String, ByVal pSeparacionVentaDetalle As EseparacionVentaDetalle) As Boolean
        Dim resultado As Boolean = False

        Dim options As New TransactionOptions
        options.IsolationLevel = Transactions.IsolationLevel.ReadCommitted
        options.Timeout = New TimeSpan(0, 2, 0)

        Using scope As New TransactionScope(TransactionScopeOption.Required, options)
            Try
                resultado = DseparacionVentaDetalle.AñadirVentaTemporal(descEmpresa, pSeparacionVentaDetalle)
                scope.Complete()
            Catch ex As Exception
                Throw
            End Try
        End Using

        Return resultado
    End Function
    Public Shared Function EditarTemporal(ByVal descEmpresa As String, ByVal pSeparacionVentaDetalle As EseparacionVentaDetalle) As Boolean
        Dim resultado As Boolean = False

        Dim options As New TransactionOptions
        options.IsolationLevel = Transactions.IsolationLevel.ReadCommitted
        options.Timeout = New TimeSpan(0, 2, 0)

        Using scope As New TransactionScope(TransactionScopeOption.Required, options)
            Try
                resultado = DseparacionVentaDetalle.EditarTemporal(descEmpresa, pSeparacionVentaDetalle)
                scope.Complete()
            Catch ex As Exception
                Throw
            End Try
        End Using

        Return resultado
    End Function
    Public Shared Function FiltrarTemporal(ByVal descEmpresa As String, ByVal pSeparacionVenta As EseparacionVenta) As List(Of EseparacionVentaDetalle)
        Dim separacionVentaDetalles As List(Of EseparacionVentaDetalle) = Nothing

        Dim options As New TransactionOptions
        options.IsolationLevel = Transactions.IsolationLevel.ReadCommitted
        options.Timeout = New TimeSpan(0, 2, 0)

        Using scope As New TransactionScope(TransactionScopeOption.Required, options)
            Try
                separacionVentaDetalles = DseparacionVentaDetalle.FiltrarTemporal(descEmpresa, pSeparacionVenta)
                If separacionVentaDetalles Is Nothing Then separacionVentaDetalles = New List(Of EseparacionVentaDetalle)
                scope.Complete()
            Catch ex As Exception
                Throw
            End Try
        End Using

        Return separacionVentaDetalles
    End Function
    Public Shared Function Inmuebles(ByVal descEmpresa As String, ByVal idproyecto As Int32, ByVal idEtapa As Int32, ByVal idSeparacionVenta As Int32) As List(Of EseparacionVentaDetalle)
        Dim separacionVentaDetalles As List(Of EseparacionVentaDetalle) = Nothing

        Dim options As New TransactionOptions
        options.IsolationLevel = Transactions.IsolationLevel.ReadCommitted
        options.Timeout = New TimeSpan(0, 2, 0)

        Using scope As New TransactionScope(TransactionScopeOption.Required, options)
            Try
                separacionVentaDetalles = DseparacionVentaDetalle.Inmuebles(descEmpresa, idproyecto, idEtapa, idSeparacionVenta)
                If separacionVentaDetalles Is Nothing Then separacionVentaDetalles = New List(Of EseparacionVentaDetalle)
                scope.Complete()
            Catch ex As Exception
                Throw
            End Try
        End Using

        Return separacionVentaDetalles
    End Function

    Public Shared Function consultaInmuebles(ByVal descEmpresa As String, ByVal pUnidInmobiliaria As EunidInmobiliarias) As List(Of EseparacionVentaDetalle)
        Dim separacionVentaDetalles As List(Of EseparacionVentaDetalle) = Nothing

        Dim options As New TransactionOptions
        options.IsolationLevel = Transactions.IsolationLevel.ReadCommitted
        options.Timeout = New TimeSpan(0, 2, 0)

        Using scope As New TransactionScope(TransactionScopeOption.Required, options)
            Try
                separacionVentaDetalles = DseparacionVentaDetalle.consultaInmuebles(descEmpresa, pUnidInmobiliaria)
                If separacionVentaDetalles Is Nothing Then separacionVentaDetalles = New List(Of EseparacionVentaDetalle)
                scope.Complete()
            Catch ex As Exception
                Throw
            End Try
        End Using

        Return separacionVentaDetalles
    End Function
    Public Shared Function consultaInmueble(ByVal descEmpresa As String, ByVal pUnidInmobiliaria As EunidInmobiliarias) As EseparacionVentaDetalle
        Dim separacionVentaDetalle As EseparacionVentaDetalle = Nothing

        Dim options As New TransactionOptions
        options.IsolationLevel = Transactions.IsolationLevel.ReadCommitted
        options.Timeout = New TimeSpan(0, 2, 0)

        Using scope As New TransactionScope(TransactionScopeOption.Required, options)
            Try
                separacionVentaDetalle = DseparacionVentaDetalle.consultaInmueble(descEmpresa, pUnidInmobiliaria)
                If separacionVentaDetalle Is Nothing Then separacionVentaDetalle = New EseparacionVentaDetalle
                scope.Complete()
            Catch ex As Exception
                Throw
            End Try
        End Using

        Return separacionVentaDetalle
    End Function
    Public Shared Function EditarNroPartida(ByVal descEmpresa As String, ByVal pSeparacionVentaDetalle As EseparacionVentaDetalle) As Boolean
        Dim resultado As Boolean = False

        Dim options As New TransactionOptions
        options.IsolationLevel = Transactions.IsolationLevel.ReadCommitted
        options.Timeout = New TimeSpan(0, 2, 0)

        Using scope As New TransactionScope(TransactionScopeOption.Required, options)
            Try
                resultado = DseparacionVentaDetalle.EditarNroPartida(descEmpresa, pSeparacionVentaDetalle)
                scope.Complete()
            Catch ex As Exception
                Throw
            End Try
        End Using

        Return resultado
    End Function

    '-------   REPORTE VENDEDOR - COMISION SEPARACION -------'
    Public Shared Function seleccionar_selXVendedorComisionSeparacion(ByVal descEmpresa As String, ByVal pSeparacionVenta As EseparacionVentaDetalle, ByVal filtro As String) As List(Of EseparacionVentaDetalle)
        Dim vendedorComisiones As List(Of EseparacionVentaDetalle) = Nothing

        Dim options As New TransactionOptions
        options.IsolationLevel = Transactions.IsolationLevel.ReadCommitted
        options.Timeout = New TimeSpan(0, 2, 0)

        Using scope As New TransactionScope(TransactionScopeOption.Required, options)
            Try
                vendedorComisiones = DseparacionVentaDetalle.seleccionar_selXVendedorComisionSeparacion(descEmpresa, pSeparacionVenta, filtro)
                If vendedorComisiones Is Nothing Then vendedorComisiones = New List(Of EseparacionVentaDetalle)
                scope.Complete()
            Catch ex As Exception
                Throw
            End Try
        End Using

        Return vendedorComisiones
    End Function
    Public Shared Function seleccionar_selXVendedorComisionVentas(ByVal descEmpresa As String, ByVal pSeparacionVenta As EseparacionVentaDetalle, ByVal filtro As String) As List(Of EseparacionVentaDetalle)
        Dim vendedorComisiones As List(Of EseparacionVentaDetalle) = Nothing

        Dim options As New TransactionOptions
        options.IsolationLevel = Transactions.IsolationLevel.ReadCommitted
        options.Timeout = New TimeSpan(0, 2, 0)

        Using scope As New TransactionScope(TransactionScopeOption.Required, options)
            Try
                vendedorComisiones = DseparacionVentaDetalle.seleccionar_selXVendedorComisionVentas(descEmpresa, pSeparacionVenta, filtro)
                If vendedorComisiones Is Nothing Then vendedorComisiones = New List(Of EseparacionVentaDetalle)
                scope.Complete()
            Catch ex As Exception
                Throw
            End Try
        End Using

        Return vendedorComisiones
    End Function

    '-------    REPORTE MENU - CONSULTAR VENTA DETALLE    ------------'
    Public Shared Function ReporteSeparacionDetalle(ByVal descEmpresa As String, ByVal DisplaySelect As Boolean, ByVal pSeparacionVenta As EseparacionVenta) As List(Of EseparacionVentaDetalle)
        Dim ventaDetalles As List(Of EseparacionVentaDetalle) = Nothing

        Dim options As New TransactionOptions
        options.IsolationLevel = Transactions.IsolationLevel.ReadCommitted
        options.Timeout = New TimeSpan(0, 2, 0)

        Using scope As New TransactionScope(TransactionScopeOption.Required, options)
            Try
                ventaDetalles = DseparacionVentaDetalle.ReporteSeparacionDetalle(descEmpresa, pSeparacionVenta)
                If ventaDetalles Is Nothing Then ventaDetalles = New List(Of EseparacionVentaDetalle)

                scope.Complete()
            Catch ex As Exception
                Throw
            End Try
        End Using

        Return ventaDetalles
    End Function
    Public Shared Function ReporteVentaDetalle(ByVal descEmpresa As String, ByVal DisplaySelect As Boolean, ByVal pSeparacionVenta As EseparacionVenta) As List(Of EseparacionVentaDetalle)
        Dim ventaDetalles As List(Of EseparacionVentaDetalle) = Nothing

        Dim options As New TransactionOptions
        options.IsolationLevel = Transactions.IsolationLevel.ReadCommitted
        options.Timeout = New TimeSpan(0, 2, 0)

        Using scope As New TransactionScope(TransactionScopeOption.Required, options)
            Try
                ventaDetalles = DseparacionVentaDetalle.ReporteVentaDetalle(descEmpresa, pSeparacionVenta)
                If ventaDetalles Is Nothing Then ventaDetalles = New List(Of EseparacionVentaDetalle)

                scope.Complete()
            Catch ex As Exception
                Throw
            End Try
        End Using

        Return ventaDetalles
    End Function

    '-------    REPORTE MENU - CONSULTAR VENTA DETALLE TEMPORAL    ------------'
    Public Shared Function ReporteSeparacionDetalleTemporal(ByVal descEmpresa As String, ByVal DisplaySelect As Boolean, ByVal pSeparacionVenta As EseparacionVenta) As List(Of EseparacionVentaDetalle)
        Dim ventaDetalles As List(Of EseparacionVentaDetalle) = Nothing

        Dim options As New TransactionOptions
        options.IsolationLevel = Transactions.IsolationLevel.ReadCommitted
        options.Timeout = New TimeSpan(0, 2, 0)

        Using scope As New TransactionScope(TransactionScopeOption.Required, options)
            Try
                ventaDetalles = DseparacionVentaDetalle.ReporteSeparacionDetalleTemporal(descEmpresa, pSeparacionVenta)
                If ventaDetalles Is Nothing Then ventaDetalles = New List(Of EseparacionVentaDetalle)

                scope.Complete()
            Catch ex As Exception
                Throw
            End Try
        End Using

        Return ventaDetalles
    End Function
    '------------------------------------------------'
End Class
